﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using OrganizedIN.BAL;
using OrganizedIN.BussinessServices;

namespace OrganizedIN.UI.AccountSetting
{
    public partial class GroupUpdate : System.Web.UI.Page
    {
        OIDataContext dc = new OIDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    fillInformation();
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void fillInformation()
        {
            if (Request["GroupID"] != null)
            {
                int GroupID = Convert.ToInt32(Request["GroupID"]);
                var data = (from d in dc.Group_Masters
                            where d.Group_ID == GroupID
                            select d).SingleOrDefault();
                if (data != null)
                {
                    txtApproveGroupEmail.Text = data.Group_ApprovelEmail;
                    txtGroupDirectory.Text = data.Group_Directory;
                    txtSecurityAns.Text = data.Group_Secquestion;
                    txttruncate.Text = data.Group_TruncateEmail;
                }
            }
        }
        protected void btnsubmit_Click(object sender, EventArgs e)
        {
            try
            {
                int GroupID = Convert.ToInt32(Request["GroupID"]);
                var data = (from d in dc.Group_Masters
                            where d.Group_ID == GroupID
                            select d).SingleOrDefault();
                data.Group_Directory = txtGroupDirectory.Text;
                data.Group_Secquestion = txtSecurityAns.Text;
                data.Group_ApprovelEmail = txtApproveGroupEmail.Text;
                data.Group_TruncateEmail = txttruncate.Text;
                dc.SubmitChanges();         
                clearAll();
                Response.Redirect("GroupSetting.aspx");
            }
            catch (Exception ex)
            {
            }
        }
        private void clearAll()
        {
            txtApproveGroupEmail.Text = "";
            txtGroupDirectory.Text = "";
            txtSecurityAns.Text = "";
            txttruncate.Text = "";
        }



    }
}
